import pandas as pd
import numpy as np

world = pd.read_csv(r'D:\pycharm\temp\covid-19\world.csv', encoding='gbk')
dm = world.loc[world.country == '丹麦', :]

def generate_date(df):
    """

    :param df: pd.DataFrame
    :return: pd.DataFrame
    """
    years = ['2022', '2021', '2022']
    pos = 0
    dates = []
    for date in df.date:
        date = str(date)
        if date == '12.31':
            pos += 1
        date = date.split('.')
        date.insert(0, years[pos])
        dates.append('-'.join(date))
    df['dates'] = dates

generate_date(dm)
